using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace DataLayerTest.Models.Mapping
{
    public class IndoorExerciseResultMap : EntityTypeConfiguration<IndoorExerciseResult>
    {
        public IndoorExerciseResultMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            // Table & Column Mappings
            this.ToTable("IndoorExerciseResult");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.IdExercise).HasColumnName("IdExercise");
            this.Property(t => t.Score).HasColumnName("Score");
            this.Property(t => t.DateTime).HasColumnName("DateTime");

            // Relationships
            this.HasRequired(t => t.IndoorExercisePersonal)
                .WithMany(t => t.IndoorExerciseResults)
                .HasForeignKey(d => d.IdExercise);

        }
    }
}
